<?php

use Biz\service\salesRebate\SalesRebate as sSalesRebate;

class GetApplyAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REALNAME;
    const PAGE_SIZE = 30;

    public function main()
    {
        $uid = $this->uid;
        $page = $this->getRequest()->getPost('page', '');
        $page = $page ? $page : 1;
        $type = $this->getRequest()->getPost('type', '');

        $where = [
            'uid' => $uid,
            'ORDER' => ['id' => 'DESC'],
            'LIMIT' => [($page - 1) * self::PAGE_SIZE, self::PAGE_SIZE],
        ];
        if ($type > 0) {
            $where['type'] = $type;
        }
        $result = sSalesRebate::getApply($where, $page, self::PAGE_SIZE);

        $this->setSuccess($result);
    }

}